<form action="" method="post">
    验证邮政编码格式是否正确 <br>
    <input type="text" name="postalcode">
    <input type="submit" name="sub" value="验证">
</form>
<?php
/**
 * User: lie
 * Date: 2020/12/8 13:54
 * Title: 验证邮政编码格式是否正确
 * Description:
 * Error:
 */
if ($_POST['sub']) {
    if (preg_match("/^[1-9][0-9]{5}$/", $_POST['postalcode'])) {
        echo "正确的";
    } else {
        echo "错误的";
    }
}
